package homework1;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Field;
import java.sql.Connection;
import java.sql.Date;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.naming.NamingException;
import javax.sql.DataSource;
public class DataBaseController //数据库操作类
{
	Connection connection;
	Driver driver;
	static DataBaseController myBase=null;
	String url="jdbc:mysql://localhost:3306/homework1?user=root&password=&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull";
	private DataBaseController()
	{
		try 
		{
			Class.forName("com.mysql.jdbc.Driver").newInstance(); 
			connection = DriverManager.getConnection(url);
			driver = DriverManager.getDriver(connection.getMetaData().getURL());
		} catch (Exception e) 
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static DataBaseController getDBConnecter()
	{
		if(myBase==null) myBase=new DataBaseController();
		return myBase;
	}
	
	
}
